﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace NWBA_Public
{
    public partial class MyProfile : System.Web.UI.Page
    {
        public Customer cust;
        protected void Page_Load(object sender, EventArgs e)
        {
            String userName = (string)(Session["userName"]);
            if (userName == null)
            {
                Response.Redirect("Login.aspx", true);
            }
            cust = Session["Customer"] as Customer;
            Session["ID"] = cust.CustomerID;
        }
        protected void DDLState_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextBox textbox = FormView1.FindControl("StateTextBox") as TextBox;
            DropDownList drop= FormView1.FindControl("DDLState") as DropDownList;
            string value = drop.SelectedValue;
            textbox.Text = value;
            
        }

        protected void digitCheck_ServerValidate(object source, ServerValidateEventArgs args)
        {
                args.IsValid = (args.Value.Length == 4 || args.Value.Length == 0);
        }

        protected void phoneValidator_ServerValidate(object source, ServerValidateEventArgs args)
        {
            try
            {
                int num = int.Parse(args.Value);
                args.IsValid = (args.Value.ToString().Length == 8);
            }
            catch (Exception ex)
            {
                args.IsValid = false;
            }
        }

        protected void BtnChangePassword_Click(object sender, EventArgs e)
        {
            string id = Session["Username"].ToString();
            if (Page.IsValid)
            {
                if (LoginUpdate.updatePassword(id, tbPass1.Text))
                {
                    Response.Redirect("TransactionStatue.aspx", true);
                }
            }
        }

    }
}